package UserEndpoint


//endpoint是定义Request和Response格式，
//接受request调用Service层处理处理，返回相应的response
import (
	"12.2-gokit/Services/UserService"
	"context"
	"github.com/go-kit/kit/endpoint"
)

type UserRequest struct {
	Uid int`json:"uid"`
}

type UserResponse struct {
	Result string`json:"result"`
}

//type Endpoint func(ctx context.Context, request interface{}) (response interface{}, err error)
func GenUserEndpoint(userSercive UserService.IUserService) endpoint.Endpoint {
	return func(ctx context.Context, request interface{}) (response interface{}, err error) {
		r := request.(UserRequest)//断言
		name := userSercive.GetName(r.Uid)
		//断言后就得到了Uid
		//有了Uid我们就可以
		return UserResponse{Result: name}, nil
	}
}
